package com.my.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 请求转发跳转
 * 可以让请求从服务端跳转到客户端，或者跳转到指定的Servlet
 *
 * 特点：
 *      1、服务端行为
 *      2、地址栏不发生改变
 *      3、从始至终只有一个请求
 *      4、request数据可以共享
 */
@WebServlet("/s03")
public class Servlet03 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    //接受客户端请求的参数
        String uname = req.getParameter("uname");
        System.out.println("Servlet03 uname:"+uname);

        //1、请求转发跳转到Servlet04
       // req.getRequestDispatcher("s04").forward(req,resp);

        //2、请求转发到jsp页面
        //req.getRequestDispatcher("login.jsp").forward(req,resp);

        //3、请求转发到html页面
        req.getRequestDispatcher("login.html").forward(req,resp);
    }
}